package day12.console.impl;

import day12.console.ConsoleCommand;
import day12.packet.request.LoginRequestPacket;
import day12.util.LoginUtil;
import io.netty.channel.Channel;

import java.util.Scanner;

/**
 * @author chenshijie
 * @date 2024/1/1 14:30
 */

public class LoginConsoleCommand implements ConsoleCommand {
    @Override
    public void exec(Scanner sc, Channel channel) {
        // 未登录
        LoginRequestPacket loginRequestPacket = new LoginRequestPacket();
        System.out.println("输入用户名登录: ");
        String username = sc.nextLine();
        loginRequestPacket.setUsername(username);
        System.out.println("输入密码: ");
        String password = sc.nextLine();
        loginRequestPacket.setPassword(password);
        loginRequestPacket.setLoginStatus(LoginUtil.LOGIN);
        channel.writeAndFlush(loginRequestPacket);
    }
}
